package net.bplaced.streetfighter.lib.async.task;

import net.bplaced.streetfighter.lib.model.AppVersion;
import net.bplaced.streetfighter.lib.service.UpdateCheckService;
import net.bplaced.streetfighter.lib.utils.CallBack;
import net.bplaced.streetfighter.lib.utils.ServiceReturnPackage;
import android.content.Context;

/**
 * @author Sebastian Hoffmann <bo.hoffi@googlemail.com>
 */
public class UpdateCheckerTask
        extends AbstractLoaderTask<String, ServiceReturnPackage<AppVersion[]>> {

    public UpdateCheckerTask(Context context, String progressMessage,
            CallBack<ServiceReturnPackage<AppVersion[]>> onFinished) {

        super(context, progressMessage, onFinished);
    }

    @Override
    ServiceReturnPackage<AppVersion[]> performInBackground(String... params) {

        if (params.length != 1) {
            return null;
        }

        return new UpdateCheckService().fetchVersionsViaPOST(params[0]);
    }
}